<?php
class noten_model extends CI_Model {

	public function __construct()
	{
		$this->load->database();
	}
	
	public function get_noten()
	{
		$query = $this->db->get('noten');
		return $query->result_array();		
	}
	
	public function get_count()
	{
		return $this->db->count_all_results('noten');
	}
	
	public function get_all($limit,$offset)
	{
		$this->db->limit($limit,$offset);
		$query = $this->db->get('noten');
		return $query->result_array();
	}
	
	public function get_noten_id($notencode)
	{
   		$this -> db -> from('noten');
		$this -> db -> where('Code', $notencode);
		
		$query = $this -> db -> get();
		return $query->row_array();
	}
	
	public function set_noten()
	{
		$this->load->helper('url');

		$data = array(
			'Beschreibung' => $this->input->post('Beschreibung'),
			'Code' => $this->input->post('Code'),
		);

		return $this->db->insert('noten', $data);
	}
	
	public function validate_noten($notencode)
	{
		$data = array(
			'Beschreibung' => $this->input->post('Beschreibung'),
		);

		$where = array('Code' => $notencode);
		return  $this->db->update('noten',$data,$where);
	}
	
}
?>